package com.zzzyh.forumsystemclient.services.impl;

import com.zzzyh.forumsystemclient.common.AppResult;
import com.zzzyh.forumsystemclient.common.ResultCode;
import com.zzzyh.forumsystemclient.dao.User_RoleMapper;
import com.zzzyh.forumsystemclient.exception.AppException;
import com.zzzyh.forumsystemclient.model.User_Role;
import com.zzzyh.forumsystemclient.services.IUser_RoleServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 郑雨杭
 * @create 2025/5/30 - 10:51
 */
@Service
public class User_RoleServicesImpl implements IUser_RoleServices {
    @Autowired
    private User_RoleMapper user_roleMapper;
    @Override
    public void createUser_Role(User_Role user_role) {
        if (user_role == null || user_role.getUserId() == null || user_role.getRoleId() == null)
            throw new AppException(AppResult.failed(ResultCode.FAILED_PARAM_ERROR));
        int i = user_roleMapper.insertSelective(user_role);
        if (i <= 0)
            throw new AppException(AppResult.failed(ResultCode.FAILED_DB_ERROR));
    }
}
